const { defineConfig } = require("@vue/cli-service");
const path = require("path");

function resolve(dir) {
  return path.join(__dirname, dir);
}
const PORT = process.env.PORT || 8686;

module.exports = defineConfig({
  publicPath: "/",
  outputDir: "dist",
  assetsDir: "static",
  lintOnSave: false,
  productionSourceMap: false,
  transpileDependencies: true,
  devServer: {
    port: PORT,
    open: true,
    hot: true,
    compress: true,
    proxy: {
      "/dvproxy_pass": {
        target: "https://test-open.gangtise.com.cn", //目标接口域名
        // target: "https://open.gangtise.com", //目标接口域名
        changeOrigin: true,
      },
      "/obsproxy": {
        target: 'https://test-open.gangtise.com.cn', //目标接口域名
        // target: "https://open.gangtise.com", //目标接口域名
        changeOrigin: true,
      },
      "/staticobs": {
        target: 'https://test-open.gangtise.com.cn', //目标接口域名
        // target: "https://open.gangtise.com", //目标接口域名
        changeOrigin: true,
      },
      "/newsstaticobs": {
        target: "https://test-open.gangtise.com.cn", //目标接口域名
        // target: "https://open.gangtise.com", //目标接口域名
        changeOrigin: true,
      },
      '/requestBaseApi': {
        // target: 'https://test-open.gangtise.com.cn',
        target: 'https://open.gangtise.com.cn',
        changeOrigin: true,
        // pathRewrite: { "^/requestBaseApi/": "" }
      },
      "/application": {
        target: 'https://test-open.gangtise.com.cn', //目标接口域名
        // target: "https://open.gangtise.com", //目标接口域名
        // target: 'http://192.168.1.188:31670', // 开发环境
        changeOrigin: true,
        // pathRewrite: { "^/application": "" }
      },
      "/sinahq": {
        target: " http://hq.sinajs.cn",
        changeOrigin: true,
        pathRewrite: { "^/sinahq": "" },
        headers: {
          Referer: "https://www.sina.com.cn/",
        },
      },
      "/wskt": {
        target: "wss://w.sinajs.cn",
        ws: true,
        changeOrigin: true,
        headers: {
          Referer: "https://www.sina.com.cn/",
        },
      },
      sinacnrank: {
        target: "https://cnrank.finance.sina.cn",
        secure: true,
        changeOrigin: true,
        pathRewrite: { "^/sinacnrank": "" },
      },
      sinaquote: {
        target: "http://quotes.sina.cn",
        secure: true,
        changeOrigin: true,
        pathRewrite: { "^/sinaquote": "" },
      },
      sinafinance: {
        target: "https://finance.sina.com.cn",
        secure: true,
        changeOrigin: true,
        pathRewrite: { "^/sinafinance": "" },
      },
      sinanews: {
        target: "https://stocknews.cj.sina.cn",
        secure: true,
        changeOrigin: true,
        pathRewrite: { "^/sinanews": "" },
      },
      sinastock: {
        target: "https://stock.finance.sina.com.cn",
        secure: true,
        changeOrigin: true,
        pathRewrite: { "^/sinastock": "" },
      },
    },
  },
  configureWebpack: {
    resolve: {
      alias: {
        "@": resolve("src"),
      },
    },
  },
});
